package com.chencs.lm.controller;

import com.chencs.common.menu.controller.MenuController;
import com.chencs.lm.service.LmWebMemberSer;
import com.chencs.utils.JumpUtils;
import com.chencs.utils.SessionUtils;
import com.chencs.vo.biz.lianmeng.LmUser;
import framework.model.ResponseOptUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpSession;

@RestController
@RequestMapping("/web/member")
public class LmWebMemberCtr {

    private static final Logger logger = LoggerFactory.getLogger(LmWebMemberCtr.class);

    @Autowired
    private LmWebMemberSer memberSer;
    /**
     *
     * @param session
     * @return
     */
    @RequestMapping(value = "/listPage", method = RequestMethod.GET)
    public ModelAndView listPage(HttpSession session) {
        ModelAndView modelAndView = new ModelAndView();
        LmUser user = SessionUtils.getUser(session);
        if(user==null){
            return JumpUtils.jumpLogin();
        }else{
            modelAndView.setViewName("lm/biz/member/member_list");
        }
        return modelAndView;
    }


    @RequestMapping(value = "/member_list", method = RequestMethod.GET)
    public String member_list() {
        System.out.println("member_list_----------------------------");
        String retStr = "";
        try {
            retStr = memberSer.getList();
        } catch (Exception e) {
            retStr = ResponseOptUtil.commonMsgError( ResponseOptUtil.RET_FAIL_MSG);
            e.printStackTrace();
        }
        logger.info("member_list param: {}", retStr);
        return retStr;
    }



}
